package com.auxgroup.smarthome.job;

import com.auxgroup.smarthome.service.inner.DeviceModelInfoInnerService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * Created by niuGuangzhe on 2017/8/24.
 */
//@Component
public class CatchMesSnModelMappingJob implements SimpleJob {

    private final static Logger log= LoggerFactory.getLogger(CatchMesSnModelMappingJob.class);

    @Autowired
    private DeviceModelInfoInnerService deviceModelInfoInnerService;

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("时间到了，开始执行任务"+shardingContext.getShardingItem());
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, -1);    //得到前一天
        String  yesterday= new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());

        deviceModelInfoInnerService.igniteFuse(yesterday);

        log.info("指令下发完成，等待任务执行完毕，完成情况以及错误情况可以在配置路径中查看日志");
    }
}
